<?php

class ActionIndex extends BaseAction
{
    public function run()
    {
        if ( !Yii::app()->user->hasState('pages') )
        {
            Yii::app()->user->setState('pages', 100);
        }

        if ( ($iPages = Yii::app()->request->getParam('pages')) )
        {
            Yii::app()->user->setState('pages', $iPages);
        }
        
        $iPagesState = Yii::app()->user->getState('pages');

        $oCriteria = new CDbCriteria();
        $oCriteria->order = 'news_cdate DESC';
        
        $oDataProvider = new CActiveDataProvider('News', array
        (
            'criteria'   => $oCriteria,
            'pagination' => array
            (
                'pageSize' => $iPagesState
            )
        ));

        $this->template->iPagesState   = $iPagesState;
        $this->template->oDataProvider = $oDataProvider;
    }
}